﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace CPPEI.Coolzon.Designer.UI.Editor
{
    [Obsolete("暂不使用")]
    public class PropertyValueEditorFactory
    {
        private static Dictionary<Type, Type> s_editorDict;

        public static void Init()
        {
            s_editorDict = new Dictionary<Type, Type>();

            // register editor
            s_editorDict.Add(typeof(string), typeof(StringEditor));
            s_editorDict.Add(typeof(double), typeof(DoubleEditor));
            s_editorDict.Add(typeof(double?), typeof(DoubleEditor));
            s_editorDict.Add(typeof(Brush), typeof(BrushEditor));
            s_editorDict.Add(typeof(Thickness), typeof(ThinknessEditor));
        }

        public static PropertyValueEditor GetEditor(Type valueType)
        {
            if (s_editorDict == null)
            {
                Init();
            }

            if (s_editorDict.ContainsKey(valueType))
            {
                Type editorType = s_editorDict[valueType];
                return (PropertyValueEditor)editorType.Assembly.CreateInstance(editorType.FullName);
            }
            return null;
        }
    }
}
